﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using VsxFactory.Modeling.Repository;

namespace VsxFactory.Modeling.Strategies
{
    /// <summary>
    /// Classe permettant de spécifier une classe comme étant une stratégie devant être importée
    /// </summary>
    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class StrategyAttribute : ExportAttribute
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="StrategyAttribute"/> class.
        /// </summary>
        public StrategyAttribute(string name) : base("Strategy", typeof(IGenerationStrategy)) 
        {
            this.Name = name;
        }

        /// <summary>
        /// Name of the strategy
        /// </summary>
        /// <value>The extension.</value>
        public string Name { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>The extension.</value>
        public string Extension { get; set; }

        public string Description { get; set; }
    }

    /// <summary>
    /// Classe permettant de spécifier une classe comme étant une stratégie devant être importée
    /// </summary>
    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class StrategyProviderAttribute : ExportAttribute
    {
        internal const string StandardStrategy = "Standard strategies";

        public StrategyProviderAttribute()
            : base("Provider", typeof(IStrategyProvider))
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="StrategyAttribute"/> class.
        /// </summary>
        public StrategyProviderAttribute(string packageName) : base("Provider", typeof(IStrategyProvider))
        {
            if (String.IsNullOrWhiteSpace(packageName))
                throw new ArgumentException("packageName");
            this.PackageName = packageName;
            this.IsInternal = packageName == StandardStrategy;
        }

        public bool IsInternal { get; internal set; }
        public string PackageName { get; set; }
        public string Description { get; set; }
    }
}
